﻿using System.Drawing.Imaging;
using System.Drawing;
using System.Windows.Forms;

namespace VideoMergeSplitApp.utils
{
    internal class ViewUtil
    {

        // 获取截图并保存到桌面
        public static void ExportControlView(Control control, string filePath)
        {
            // 创建一个与PictureBox大小相同的Bitmap对象
            Bitmap bitmap = new Bitmap(control.Width, control.Height);

            // 创建一个Graphics对象，并将其绑定到Bitmap上
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                // 将PictureBox的内容绘制到Bitmap上
                graphics.CopyFromScreen(control.PointToScreen(Point.Empty), Point.Empty, control.Size);
            }

            bitmap.Save(filePath, ImageFormat.Jpeg);
        }

    }
}
